//
//  Region.swift
//  WuYeUser
//
//  Created by swordjoy on 2017/6/1.
//  Copyright © 2017年 com.WuyeUser.remotevillage. All rights reserved.
//

import Foundation
import SwiftyJSON

// 
struct RegionModel: ModelProtocol {
  
  let id: String
  let name: String
  let childrens: [RegionModel]
  
  init(json: JSON) {
    id = json["id"].stringValue
    name = json["name"].stringValue
    childrens = RegionModel.array(from: json["children"].arrayValue)
  }
  
  static func array(from jsonArray: [JSON]) -> [RegionModel] {
    return jsonArray.map({ return RegionModel(json: $0) })
  }
  
}
